package core.tool.bpe.action;

import java.util.ArrayList;
import java.util.List;

import org.dom4j.Element;

import core.tool.bpe.Action;
import core.tool.bpe.ActionType;
import core.tool.bpe.BpeContext;
import core.tool.io.FileHelper;
import core.tool.xml.dom4j.jaxb.XmlHelper;
@ActionType("DELETE_FILE")
public class DeleteDocumentsAction extends Action{

	@Override
	protected boolean execute(BpeContext bpeContext) {
		List<String> returnList=new ArrayList<String>();
		List<Element> list=XmlHelper.selectSingleElements(bpeContext.getElement(), "DeleteFiles/DeleteFile");
		for(Element temp:list) {
			String path=XmlHelper.getElementAttribute(temp, "sourceDir");
			returnList.add(path);
		}		
		FileHelper.deleteFile(returnList);	
		return true;
	}
}
